package com.itheima.mq;

import com.itheima.sms.SMSUtil;
import com.itheima.utils.RedisUtil;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;


@Component
public class SmsCodeConsumer {

    @RabbitListener(queues = "test")
    public void reciver(String telephone){
//       String code = SMSUtil.sendSmsValidCode(telephone);
        String code = SMSUtil.generatorCode(4);

        System.out.println("短信验证码:" + code);

        //Redis
        RedisUtil.set("sms:code:" + telephone,code,5L, TimeUnit.MINUTES);
    }

}
